home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1 Issue 2 / PDCD-1 - Issue 02.iso / _utilities / utilities / 003 / _addtopath / AddPathSrc (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1994-10-16  |  3KB  |  95 lines

  1.  > AddPathSrc
  2. fnm$="AddToPath"
  3. ;bl$=
  4. 0:cr$=
  5. 13:lfcr$=
  6. 10+cr$:tab$=
  7. 9:esc$=
  8. 27:hspc$=
  9. 1codesize=&1000:
  10.  org codesize:L%=org+codesize
  11.  A%=%1100 
  12.  %1110 
  13.  %0010
  14. ?P%=0:O%=org : 
  15.  So that addresses are offsets within module
  16. [OPT A%
  17. J; /E R0->command, R1->command tail, R12->1024 bytes workspace, R13 SP,
  18. ;    R14 link, 
  19.  mode
  20.             MOV     R8,R14
  21. O            MOV     R11,#0               ; Load a handy zero into spare reg
  22.             MOV     R7,R1
  23.             MOV     R5,R1
  24. $.findarg2lp LDRB    R14,[r5,#1]!
  25.             CMP     R14,#32
  26. "            BGT     findarg2lp
  27.              STREQB  R11,[r5]
  28. .findarg2lp2
  29. $            LDREQB  R14,[r5,#1]!
  30.             CMPEQ   R14,#32
  31. #            BEQ     findarg2lp2
  32. =            MOVLT   PC,R8                ; No second arg!
  33. G            MOV     R4,#0                ; Don't expand into string
  34. D.itsanumber MOV     R0,R7                ; Start of command line
  35.             MOV     R1,R12
  36.              MOV     R2,#1024
  37.             MOV     R3,#0
  38.  (            SWI     "XOS_ReadVarVal"
  39. !$            BVS     needtocreate
  40. "N            TEQ     R4,#1                ; If some hacker has set xxx$Path
  41. #M            
  42. Q   R4,#3                ; to a number, convert to a string,
  43. $"            BEQ     itsanumber
  44. %?            STRB    R11,[R1,R2]          ; Terminate string
  45. &/            ; R1->xxx$path, R5->path to add
  46.             MOV     R3,R5
  47.             MOV     R5,R1
  48. .complp     MOV     R0,R5
  49. *".despacelp  LDRB    R2,[R1],#1
  50. +;            TEQ     R2,#32               ; Strip spaces
  51. ,"            STRNEB  R2,[R5],#1
  52.             TEQ     R2,#0
  53. .             TEQNE   R2,#
  54. /!            BNE     despacelp
  55. 0$            STRB    R11,[R5,#-1]
  56.             MOV     R4,R3
  57. 2?.strcmplp   LDRB    R14,[R4],#1          ; strcmp r0 and r4
  58. 3"            LDRB    R6,[R0],#1
  59. 4!            
  60. RS    R10,R6,R14
  61. 5N            
  62. Q   PC,R8                ; Component already in path variable
  63.             TEQ     R6,R14
  64. 7             BEQ     strcmplp
  65.             TEQ     R2,#0
  66. 9#            STRNEB  R2,[R5,#-1]
  67.             BNE     complp
  68. ;!            MOV     R14,#
  69. <B            STRB    R14,[R5,#-1]         ; Need to add to path
  70. =#.copylp     LDRB    R14,[R3],#1
  71.             CMP     R14,#32
  72. ?#            STRGTB  R14,[R5],#1
  73.             BGT     copylp
  74.             MOV     R1,R12
  75. B .create     STRB    R11,[R5]
  76.             MOV     R0,R7
  77. D             SUB     R2,R5,R1
  78.             MOV     R3,#0
  79. F4            MOV     R4,#2                ; Macro
  80. G'            SWI     "XOS_SetVarVal"
  81.             MOV     PC,R8
  82. .needtocreate
  83.             MOV     R1,R5
  84. L$.countlp    LDRB    R14,[R5,#1]!
  85.             CMP     R14,#32
  86.             BGT     countlp
  87.             B       create
  88. "Size = ";P%" bytes"
  89.  "OS_File",&0A,fnm$,&FFC,,org,O%
  90. align
  91.  next line allows shuffling of strings to reduce wastage
  92. 2)=0 
  93. 3" byte(s) wasted by FNalign"
  94. 3:[OPTA%:EQUB0:]:
  95.